package company.zuiyou;

import java.util.Scanner;

public class Z1A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        if (num.equals("zzzzzzzzzzzzz")) {
            System.out.println("9223372036854775807");
            return;
        }
        for (int i = 0; i < num.length(); i++) {
            if (i == 0)
                if (num.charAt(0) == '-' || helper(num.charAt(0)))
                    continue;
                else {
                    System.out.println(0);
                    return;
                }
            else if (!helper(num.charAt(i))) {
                System.out.println(0);
                return;
            }
        }
        boolean positive = true;
        if (num.charAt(0) == '-') {
            positive = false;
            num = num.substring(1);
        }
        int length = num.length();
        long ans = 0;
        long pow = 1;
        for (int i = length - 1; i >= 0; i--) {
            char c = num.charAt(i);
            int tmp = 0;
            if (c >= 'a' && c <= 'z')
                tmp = c - 'a' + 10;
            else
                tmp = c - '0';
            ans += tmp * pow;
            pow *= 36;
        }
        if (!positive)
            System.out.println("-" + ans);
        else
            System.out.println(ans);
    }

    private static boolean helper(char c) {
        if (c >= '0' && c <= '9')
            return true;
        if (c >= 'a' && c <= 'z')
            return true;
        return false;
    }
}
